use std::collections::VecDeque;
use utils::math::{miller_rabin_2, pollard_rho};

pub fn find_max_prime_factor(number: u128) -> u128 {
    let mut queue = VecDeque::from([number]);
    let mut max_prime = 0;
    while let Some(num) = queue.pop_front() {
        if num == 1 {
            continue;
        }
        if miller_rabin_2(num) {
            if num > max_prime {
                max_prime = num;
            }
            continue;
        }
        let factor = pollard_rho(num);
        queue.push_back(factor);
        queue.push_back(num / factor);
    }
    max_prime
}
